package com.chem.search.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chem.search.entity.ShortPage;
import com.chem.search.mapper.ShortPageMapper;
import com.chem.search.service.ShortPageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 权哥
 * @version 1.0
 * @date 2023/9/14 22:24
 */
@RestController
@RequestMapping("/search")
public class SearchController {


    @Autowired
    private ShortPageMapper shortPageMapper;


    @PostMapping("/short_page_")
    public Page<ShortPage> search_(String key){
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.like("content",key);

        Sort sort = Sort.by(Sort.Direction.ASC,"id");
        Page<ShortPage> page = new Page<>(1, 10);

        return shortPageMapper.selectPage(page,wrapper);
    }


}
